<template>
	<view>
		<text>欢迎：{{staff.name}}</text>
		
	</view>
</template>

<script>
	
	import request from '../../common/request';
	import common from 'common/common.js';
	export default {
		data() {
			return {
				staff: {},
			}
		},
		onLoad() {
			// this.staff = {
			// 	"name": "孙恒",
			// 	"userId": "sunheng",
			// 	"id":42,
			// 	"avatar":"https://wework.qpic.cn/wwpic/198136_MoYax0xZQ3KuA3G_1692579794/0"
			// }
			// uni.setStorageSync("staff", this.staff);
			this.staff = uni.getStorageSync("staff");
			// if(!document.URL.split("=")[1]){
			// } else {
			// 	this.code = document.URL.split("=")[1].split("&")[0];
			// 	this.toApp(this.code);
			// }
		},
		onShow() {
		},
		methods: {
			toApp(code){
				var _this = this;
				uni.request({
					url: common.api_base_url+'/app' ,
					data:{
							"code": code
					},
					header:{
					},
					method: 'GET',
					success: res => {
						_this.staff = res.data;
						uni.setStorageSync('staff', _this.staff);
						// uni.showToast({
						// 	title: "员工id为：" + _this.staff.id + "，员工姓名为：" + _this.staff.name,
						// 	icon:"loading"
						// })
					},
					fail: function(e) {
						uni.showToast({
							title:"唉哟，程序错误了["+JSON.stringify(e)+"]",
							icon:"loading"
						})
					},
				});
				_this.code = '';
			},
		}
	}
</script>

<style>

</style>
